package cn.com.headfree.competent.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import cn.com.headfree.entity.*;
import cn.com.headfree.competent.dao.IUserDataInfoDao;
import cn.com.headfree.competent.service.IUserDataInfoService;
import cn.com.headfree.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service("userDataInfoService")
public class UserDataInfoServiceImpl implements IUserDataInfoService {
	@Autowired
	private IUserDataInfoDao userInfoDao;

	/**
	 * 基本信息
	 * @param erpNo
	 * @return
	 */
	@Override
	public TEmpBaseInfo getBaseInfoByErpNo(String erpNo) {
		return userInfoDao.getBaseInfoByErpNo(erpNo);
	}

	/**
	 * 年度绩效
	 * @param erpNo
	 */
	public List<YearEffectVo> getYearEffectByErpNo(String erpNo){
		return userInfoDao.getYearEffectByErpNo(erpNo);
	}


	/**
	 * 专业技术资格
	 * @param erpNo
	 */
	@Override
	public List<HonorDatasVo> getProTecInfoByErpNo(String erpNo) {
		return userInfoDao.getProTecInfoByErpNo(erpNo);
	}

	/**
	 * 技能等级
	 * @param erpNo
	 */
	@Override
	public List<HonorDatasVo> getSkillLevelInfoByErpNo(String erpNo,String seniorId) {
		return userInfoDao.getSkillLevelInfoByErpNo(erpNo,seniorId);
	}


	/**
	 * 专家人才称号
	 * @param erpNo
	 */
	@Override
	public List<ExpertTitleVo> getExpertTitleInfoByErpNo(String erpNo,String seniorId) {
		return userInfoDao.getExpertTitleInfoByErpNo(erpNo,seniorId);
	}

	/**
	 * 学术成果
	 * @param erpNo
	 */
	@Override
	public List<AcadeAchiveVo> getAcadeAchiveInfoByErpNo(String erpNo,String seniorId,Date acquTime) {
		return userInfoDao.getAcadeAchiveInfoByErpNo(erpNo,seniorId,acquTime);
	}
	/**
	 * 标准制定
	 * @param erpNo
	 */
	@Override
	public List<StandInfoVo> getStandInfoByErpNo(String erpNo,String seniorId,Date acquTime) {
		return userInfoDao.getStandInfoByErpNo(erpNo,seniorId,acquTime);
	}

	/**
	 * 科技创新成果
	 * @param erpNo
	 */
	@Override
	public List<TecManInnovVo> getTecManInnovByErpNo(String erpNo, String seniorId, Date acquTime) {
		return  userInfoDao.getTecManInnovByErpNo(erpNo,seniorId,acquTime);
	}

	/**
	 * 个人荣誉
	 * @param erpNo
	 */
	@Override
	public List<HonorDatasVo> getHonnorInfoByErpNo(String erpNo,String seniorId,Date acquTime) {
		return userInfoDao.getHonnorInfoByErpNo(erpNo,seniorId,acquTime);
	}

	/**
	 * 工作经历
	 * @param erpNo
	 */
	@Override
	public List<WorkExpInfoVo> getWorkExpInfoByErpNo(String erpNo,String seniorId) {
		return userInfoDao.getWorkExpInfoByErpNo(erpNo,seniorId);
	}

	/**
	 * 在岗
	 * @param erpNo
	 */
	@Override
	public List<WorkExpInfoVo> getWorkStatusExpInfoByErpNo(String erpNo,String seniorId) {
		return userInfoDao.getWorkStatusExpInfoByErpNo(erpNo,seniorId);
	}

	/**
	 * 学历信息
	 * @param erpNo
	 */
	@Override
	public List<EducateInfoVo> getEducateInfoByErpNo(String erpNo,String seniorId) {
		return userInfoDao.getEducateInfoByErpNo(erpNo,seniorId);
	}

	/**
	 * 培训授课--培训部分
	 * @param erpNo
	 */
	@Override
	public List<StudyAndTrainVo> getContiStudyInfoByErpNo(String erpNo,String seniorId) {
		return userInfoDao.getContiStudyInfoByErpNo(erpNo,seniorId);
	}

	//培训授课--授课部分
    @Override
    public List<TeachArtVo> getContiStudyTechInfoByErpNo(String erpNo,String seniorId) {
        return userInfoDao.getContiStudyTechInfoByErpNo(erpNo,seniorId);
    }

    /**
	 * 项目课题成果
	 * @param erpNo
	 */
	@Override
	public List<SkillAndTechnicalVo> getProjAchieveInfoByErpNo(String erpNo,String seniorId) {
		return userInfoDao.getProjAchieveInfoByErpNo(erpNo,seniorId);
	}

    @Override
    public List<TeachArtVo> getTSdtTutorPrentInfoByErpNo(String erpNo,String seniorId) {
        return userInfoDao.getTSdtTutorPrentInfoByErpNo(erpNo,seniorId);
    }

	@Override
	public TSeniorCompetent getTSeniorCompetentById(String seniorId) {
		return userInfoDao.getTSeniorCompetentById(seniorId);
	}

	/**
	 * 组合各类型ID，以下载附件
	 * @param erpNo
	 * @return
	 */
	@Override
	public List<BusinessIdsVo> getBusinessIdByErpNo(String erpNo,String seniorId,Date acquTime) {
		List<BusinessIdsVo> list = new ArrayList<>();
		//基本信息
		TEmpBaseInfo baseInfo = getBaseInfoByErpNo(erpNo);
		if(baseInfo != null){
			BusinessIdsVo vo = new BusinessIdsVo();
			vo.setBusinessId(baseInfo.getId());
			vo.setTypeName("基本信息");
			list.add(vo);
		}
		//工作经历
		List<WorkExpInfoVo> tWorkExpInfos = getWorkExpInfoByErpNo(erpNo,seniorId);
		if(tWorkExpInfos != null){
			for (WorkExpInfoVo workExpInfoVo:tWorkExpInfos){
				if(workExpInfoVo.getIsHide() == null || !(workExpInfoVo.getIsHide().equals("0"))){
					BusinessIdsVo vo = new BusinessIdsVo();
					vo.setBusinessId(workExpInfoVo.getId());
					vo.setTypeName("在岗及主要工作经历");
					list.add(vo);
				}
			}
		}
		//学历、培训
		List<EducateInfoVo> educateInfos = getEducateInfoByErpNo(erpNo,seniorId);
		if(educateInfos != null){
			for (EducateInfoVo studyAndTrainVo:educateInfos){
				if(studyAndTrainVo.getIsHide() == null || !(studyAndTrainVo.getIsHide().equals("0"))) {
					BusinessIdsVo vo = new BusinessIdsVo();
					vo.setBusinessId(studyAndTrainVo.getId());
					vo.setTypeName("学历、学位信息");
					list.add(vo);
				}
			}
		}
		List<StudyAndTrainVo> studyInfos = getContiStudyInfoByErpNo(erpNo,seniorId);
		if(studyInfos != null){
			for (StudyAndTrainVo studyAndTrainVo:studyInfos){
				if(studyAndTrainVo.getIsHide() == null || !(studyAndTrainVo.getIsHide().equals("0"))) {
					BusinessIdsVo vo = new BusinessIdsVo();
					vo.setBusinessId(studyAndTrainVo.getId());
					vo.setTypeName("学习培训");
					list.add(vo);
				}
			}
		}
		//科技创新
		List<TecManInnovVo> tecManInnovs = getTecManInnovByErpNo(erpNo,seniorId,acquTime);
		if(tecManInnovs != null){
			for (TecManInnovVo tecManInnovVo:tecManInnovs){
				if(tecManInnovVo.getIsHide() == null || !(tecManInnovVo.getIsHide().equals("0"))) {
					BusinessIdsVo vo = new BusinessIdsVo();
					vo.setBusinessId(tecManInnovVo.getId());
					vo.setTypeName("科技成果获奖情况");
					list.add(vo);
				}
			}
		}
//		//项目成果
//		List<SkillAndTechnicalVo> projAchieveInfos = getProjAchieveInfoByErpNo(erpNo,seniorId);
//		if(projAchieveInfos != null){
//			for (SkillAndTechnicalVo skillAndTechnicalVo:projAchieveInfos){
//				if(skillAndTechnicalVo.getIsHide() == null || !(skillAndTechnicalVo.getIsHide().equals("0"))) {
//					BusinessIdsVo vo = new BusinessIdsVo();
//					vo.setBusinessId(skillAndTechnicalVo.getId());
//					vo.setTypeName("项目课题成果");
//					list.add(vo);
//				}
//			}
//		}
		//标准制定
		List<StandInfoVo> standAndSciences = getStandInfoByErpNo(erpNo,seniorId,acquTime);
		if(standAndSciences != null){
			for (StandInfoVo standAndScienceVo:standAndSciences){
				if(standAndScienceVo.getIsHide() == null || !(standAndScienceVo.getIsHide().equals("0"))) {
					BusinessIdsVo vo = new BusinessIdsVo();
					vo.setBusinessId(standAndScienceVo.getId());
					vo.setTypeName("重要技术报告、技术规范等");
					list.add(vo);
				}
			}
		}
		//学术成果
		List<AcadeAchiveVo> acadeAchiveInfos = getAcadeAchiveInfoByErpNo(erpNo,seniorId,acquTime);
		if(acadeAchiveInfos != null){
			for (AcadeAchiveVo acadeAchiveVo:acadeAchiveInfos){
				if(acadeAchiveVo.getIsHide() == null || !(acadeAchiveVo.getIsHide().equals("0"))) {
					BusinessIdsVo vo = new BusinessIdsVo();
					vo.setBusinessId(acadeAchiveVo.getId());
					vo.setTypeName("公开发表论文、著作等");
					list.add(vo);
				}
			}
		}
//		//师带徒信息
//		List<TeachArtVo> tSdtTutorPrentInfos = getTSdtTutorPrentInfoByErpNo(erpNo,seniorId);
//		if(tSdtTutorPrentInfos != null){
//			for (TeachArtVo teachArtVo:tSdtTutorPrentInfos){
//				if(teachArtVo.getIsHide() == null || !(teachArtVo.getIsHide().equals("0"))) {
//					BusinessIdsVo vo = new BusinessIdsVo();
//					vo.setBusinessId(teachArtVo.getId());
//					vo.setTypeName("师带徒信息");
//					list.add(vo);
//				}
//			}
//		}
//		//培训授课
//		List<TeachArtVo> contiInfos = getContiStudyTechInfoByErpNo(erpNo,seniorId);
//		if(contiInfos != null){
//			for (TeachArtVo teachArtVo:contiInfos){
//				if(teachArtVo.getIsHide() == null || !(teachArtVo.getIsHide().equals("0"))) {
//					BusinessIdsVo vo = new BusinessIdsVo();
//					vo.setBusinessId(teachArtVo.getId());
//					vo.setTypeName("培训授课");
//					list.add(vo);
//				}
//			}
//		}
		//个人荣誉
		List<HonorDatasVo> honnorInfos = getHonnorInfoByErpNo(erpNo,seniorId,acquTime);
		if(honnorInfos != null){
			for (HonorDatasVo honorDatasVo:honnorInfos){
				if(honorDatasVo.getIsHide() == null || !(honorDatasVo.getIsHide().equals("0"))) {
					BusinessIdsVo vo = new BusinessIdsVo();
					vo.setBusinessId(honorDatasVo.getId());
					vo.setTypeName("荣誉称号");
					list.add(vo);
				}
			}
		}
		//专家人才称号
		List<ExpertTitleVo> expertTitleInfos = getExpertTitleInfoByErpNo(erpNo,seniorId);
		if(expertTitleInfos != null){
			for (ExpertTitleVo honorDatasVo:expertTitleInfos){
				if(honorDatasVo.getIsHide() == null || !(honorDatasVo.getIsHide().equals("0"))) {
					BusinessIdsVo vo = new BusinessIdsVo();
					vo.setBusinessId(honorDatasVo.getId());
					vo.setTypeName("专家称号");
					list.add(vo);
				}
			}
		}
//		//专业技术资格
//		List<HonorDatasVo> proTecInfos = getProTecInfoByErpNo(erpNo,seniorId);
//		if(proTecInfos != null){
//			for (HonorDatasVo honorDatasVo:proTecInfos){
//				if(honorDatasVo.getIsHide() == null || !(honorDatasVo.getIsHide().equals("0"))) {
//					BusinessIdsVo vo = new BusinessIdsVo();
//					vo.setBusinessId(honorDatasVo.getId());
//					vo.setTypeName("专业技术资格");
//					list.add(vo);
//				}
//			}
//		}
		//近三年绩效
		List<YearEffectVo> yearEffectVos = getYearEffectByErpNo(erpNo);
		if(yearEffectVos != null){
			for (YearEffectVo yearEffectVo:yearEffectVos){
				BusinessIdsVo vo = new BusinessIdsVo();
				vo.setBusinessId(yearEffectVo.getId());
				vo.setTypeName("近三年绩效");
				list.add(vo);
			}
		}
		return list;
	}


}
